home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_Tix.idb / usr / freeware / lib / tix4.1 / demos / samples / FileEnt.tcl.z / FileEnt.tcl
Encoding:
Text File  |  1999-01-26  |  2.0 KB  |  78 lines

  1. # Tix Demostration Program
  2. #
  3. # This sample program is structured in such a way so that it can be
  4. # executed from the Tix demo program "widget": it must have a
  5. # procedure called "RunSample". It should also have the "if" statment
  6. # at the end of this file so that it can be run as a standalone
  7. # program using tixwish.
  8.  
  9. # This file demonstrates the use of the tixFileEntry widget -- an
  10. # easy of letting the user select a filename
  11. #
  12. proc RunSample {w} {
  13.  
  14.     # Create the tixFileEntry's on the top of the dialog box
  15.     #
  16.     frame $w.top -border 1 -relief raised
  17.  
  18.     global demo_fent_from demo_fent_to
  19.  
  20.     tixFileEntry $w.top.a -label "Move File From: " \
  21.     -variable demo_fent_from \
  22.     -options {
  23.         entry.width 25
  24.         label.width 16
  25.         label.underline 10
  26.         label.anchor e
  27.     }
  28.  
  29.     tixFileEntry $w.top.b -label "To: " \
  30.     -variable demo_fent_to \
  31.     -options {
  32.         entry.width 25
  33.         label.underline 0
  34.         label.width 16
  35.         label.anchor e
  36.     }
  37.  
  38.     pack $w.top.a $w.top.b -side top -anchor w -pady 3
  39.  
  40.     # Use a ButtonBox to hold the buttons.
  41.     #
  42.     tixButtonBox $w.box -orientation horizontal
  43.     $w.box add ok     -text Ok     -underline 0 -command "fent:okcmd $w" \
  44.     -width 6
  45.     $w.box add cancel -text Cancel -underline 0 -command "destroy $w" \
  46.     -width 6
  47.  
  48.     pack $w.box -side bottom -fill x
  49.     pack $w.top -side top -fill both -expand yes
  50.  
  51.     # Let's set some nice bindings for keyboard accelerators
  52.     #
  53.     bind $w <Alt-f> "focus $w.top.a" 
  54.     bind $w <Alt-t> "focus $w.top.b" 
  55.     bind $w <Alt-o> "[$w.box subwidget ok] invoke; break" 
  56.     bind $w <Alt-c> "[$w.box subwidget cancel] invoke; break" 
  57. }
  58.  
  59. proc fent:okcmd {w} {
  60.     global demo_fent_from demo_fent_to
  61.  
  62.     puts "You wanted to move file from $demo_fent_from to $demo_fent_to"
  63.  
  64.     destroy $w
  65. }
  66.  
  67.  
  68. # This "if" statement makes it possible to run this script file inside or
  69. # outside of the main demo program "widget".
  70. #
  71. if {![info exists tix_demo_running]} {
  72.     wm withdraw .
  73.     set w .demo
  74.     toplevel $w
  75.     RunSample $w
  76.     bind $w <Destroy> exit
  77. }
  78.